package com.lemner.ke.adapter;

import android.content.Intent;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lemner.ke.R;
import com.lemner.ke.activity.VideoDetailActivity;
import com.lemner.ke.base.URL;
import com.lemner.ke.bean.RecommedBean;
import com.lemner.ke.bean.VideoRvBean;
import com.lemner.ke.util.LoadImageUtils;

import java.util.List;

/**
 * 知 视频列表适配器
 * @author raintea
 * @date 2018/9/20
 */
public class VideoRvAdapter extends BaseQuickAdapter<VideoRvBean,BaseViewHolder>{
    public VideoRvAdapter(int layoutResId, @Nullable List<VideoRvBean> data) {
        super(layoutResId, data);
    }

    public VideoRvAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, final VideoRvBean item) {

        //helper.setText(R.id.item_video_title_tv,item.getTitle());
        if (item!=null){
            if (item.getCovers()!=null){
                ImageView iv = helper.getView(R.id.iv_item_video);
                LoadImageUtils.loadRoundImage(URL.BASE_URL+item.getCovers(),iv);
            }
            if (item.getHitnum()!=null){
                helper.setText(R.id.tv_video_hit,item.getHitnum()+"次播放");
            }
            if (item.getTitle()!=null){
                helper.setText(R.id.item_video_title_tv,item.getTitle());
            }
            if (item.getDescription()!=null){
                helper.setText(R.id.item_video_desc_tv,item.getDescription());
            }
            if (item.getCommentnum()!=null){
                helper.setText(R.id.item_video_comment_tv,item.getCommentnum());
            }
            if (item.getLikesnum()!=null){
                helper.setText(R.id.item_video_likesum_tv,item.getLikesnum());
            }
            helper.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent passIntent = new Intent(mContext, VideoDetailActivity.class);
                    passIntent.putExtra("bean", item);
                    mContext.startActivity(passIntent);
                }
            });
        }
    }
}
